const mongoose = require('mongoose');
//创建用户集合规则
const userSchema = new mongoose.Schema({
    name: {
        type: String,
        required: true,
        minlength: [2, '用户名最少两个字符'],
        maxlength: [20, '用户名最多20字符']
    },
    age: {
        type: Number,
        min: [18, '年龄最小18'],
        max: [80, '年龄最大80']
    },
    password: String,
    email: String,
    hobbies: [String]
});
//创建用户集合
const User = mongoose.model('User', userSchema);
module.exports = User;